import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QPushButton, QApplication, QVBoxLayout


class Winform(QWidget):
    def __init__(self,parent=None):
        super(Winform, self).__init__(parent)
        self.setWindowTitle('MOto')

        hlayout=QHBoxLayout()
        # 横向
        vlayout = QVBoxLayout()
        #纵向

        hlayout.addWidget(QPushButton(str(1)))
        hlayout.addWidget(QPushButton(str(2)))
        hlayout.addWidget(QPushButton(str(3)))
        hlayout.addWidget(QPushButton(str(4)))
        hlayout.addWidget(QPushButton(str(5)))
        hlayout.setSpacing(10)
        #间距

        #hlayout.addStretch(0)
        #拉伸为0

        vlayout.addWidget(QPushButton(str(1)))
        vlayout.addWidget(QPushButton(str(2)))
        vlayout.addWidget(QPushButton(str(3)))
        vlayout.addWidget(QPushButton(str(4)))
        vlayout.addWidget(QPushButton(str(5)))


        wlayout=QHBoxLayout()
        #全局布局

        hwg=QWidget()
        vwg=QWidget()
        #声明局部的组件

        hwg.setLayout(hlayout)
        vwg.setLayout(vlayout)
        #部分组件使用各自的布局

        wlayout.addWidget(hwg)
        wlayout.addWidget(vwg)
        #公共布局使用部分组件



        self.setLayout(wlayout)



if __name__ == '__main__':
    app = QApplication(sys.argv)
    combox = Winform()
    combox.show()
    sys.exit(app.exec_())


